package com.cetcs.kmga.common;

import org.joda.time.DateTime;

/**
 * Created by XingWen on 2017/3/7.
 */
public class DateUtil {
    private static final String DATETIME_FORMATE = "yyyy-MM-dd HH:mm:ss";
    private static final String SHORT_DATETIME_FORMATE = "yyyy-MM-dd";

    public static String getTodayShortDateFormat(){
        DateTime dateTime = new DateTime().withMillisOfDay(0);
        String date = dateTime.toString(SHORT_DATETIME_FORMATE);
        return date;
    }

    public static String getToday(){
        DateTime dateTime = new DateTime().withMillisOfDay(0);
        //For Test
        //DateTime dateTime = new DateTime().minusMinutes(10).withSecondOfMinute(0);
        //DateTime dateTime = new DateTime().withSecondOfMinute(0);
        String date = dateTime.toString(DATETIME_FORMATE);
        return date;
    }

    public static String getTomorrow(){
        //For Test
        //DateTime dateTime = new DateTime().minusMinutes(10).withSecondOfMinute(0);
        DateTime dateTime = new DateTime().plusDays(1).withMillisOfDay(0);
        String date = dateTime.toString(DATETIME_FORMATE);
        return date;
    }

    public static String getYesterday(){
        //DateTime dateTime = new DateTime().minusDays(1).withMillisOfDay(0);
        //For Test
        //DateTime dateTime = new DateTime().minusDays(2).minusMinutes(5).withSecondOfMinute(0);
        DateTime dateTime = new DateTime().minusDays(1).withMillisOfDay(0);
        String date = dateTime.toString(DATETIME_FORMATE);
        return date;
    }

    public static String getRecentlyDay(){
        DateTime dateTime = new DateTime().minusDays(3).withMillisOfDay(0);
        String date = dateTime.toString(DATETIME_FORMATE);
        return date;
    }

    public static void main(String[] args) {
        System.out.println(getYesterday());
        System.out.println(getToday());
        System.out.println(getTomorrow());
        System.out.println(getTodayShortDateFormat());
    }
}
